package com.imooc.demo.service.impl;

import com.imooc.demo.dao.OrderDao;
import com.imooc.demo.dao.WorkerDao;
import com.imooc.demo.entity.Order;
import com.imooc.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderDao orderDao;
    @Autowired
    WorkerDao workerDao;


    @Override
    public Order findOrderDetail(String orderId) {
        return orderDao.findOrderDetail(orderId).get(0);
    }

    @Override
    public boolean orderInsert(Order order) {
        return orderDao.orderInsert(order);
    }

    @Override//查找对应的订单
    public List<Order> findOrderByOrderId( String orderId) {
        return orderDao.findOrderByOrderId(orderId);
    }

    @Override
    public List<Order> findOrderByOpenid(String buyerOpenid,Integer orderStatus) {
        return orderDao.findOrderByOpenid(buyerOpenid, orderStatus);
    }

    @Override//已取消
    public boolean cancel(Order order) {
        return orderDao.cancel( order);
    }

    /////根据地址查订单
    @Override
    public List<Order> findOrderByAddressArea(String addressArea, String addressDetail ,Integer category10Id) {
        return orderDao.findOrderByAddressArea(addressArea, addressDetail ,category10Id);
    }

    @Override
    public boolean jieDan(Order order) {
        return orderDao.jieDan( order);
    }

    @Override
    public List<Order> findOrderByWorker(String workerOpenid,Integer orderStatus) {
        return orderDao.findOrderByWorker( workerOpenid, orderStatus);
        //return orderDao.findOrderByWorker( workerDao.getWorker(workerOpenid).getId(), orderStatus);
    }

    @Override
    public boolean workercancel(Order order) {
        return orderDao.workercancel( order);
    }

    @Override
    public boolean finish(Order order) {
        return orderDao.finish( order);
    }

    @Override
        //查找某人所有订单
    public List<Order> findAllOrderByOpenid(String buyerOpenid) {
        return orderDao.findAllOrderByOpenid(buyerOpenid);
    }

    @Override
    public List<Order> personOrder(String buyerOpenid, Integer orderStatus) {
        return orderDao.personOrder(buyerOpenid,orderStatus);
    }

    @Override
    public boolean setPingFen(Order order) {
        return orderDao.setPingFen(order);
    }

    @Override
    public List<Order> getAllPingFen() {
        return orderDao.getAllPingFen();
    }

}
